from selenium import webdriver
from selenium.webdriver.common.by import By
import time

d = webdriver.Chrome()
d.get("http://192.168.0.125:8008/mobile/pages/register/register")
time.sleep(1)

for i in range(100):

    # 根据时间戳生成8位数
    a = int(time.time() % 100000000)

    # 点击注册账号
    z_ele = d.find_element(By.XPATH, '/html/body/uni-app/uni-page/uni-page-wrapper/uni-page-body/uni-view/uni-view/uni-view[2]/uni-navigator')
    z_ele.click()
    # 定位手机号输入框
    s_ele = d.find_element(By.XPATH, '/html/body/uni-app/uni-page/uni-page-wrapper/uni-page-body/uni-view/uni-view[1]/uni-view[1]/uni-input/div/input')
    s_ele.send_keys(f'151{a}')
    time.sleep(1)
    # 定位设置密码输入框
    m_ele = d.find_element(By.XPATH, '/html/body/uni-app/uni-page/uni-page-wrapper/uni-page-body/uni-view/uni-view[1]/uni-view[2]/uni-input/div/input')
    m_ele.send_keys(f'xxx0{i}00')
    time.sleep(1)
    # 定位确认密码输入框
    q_ele = d.find_element(By.XPATH, '/html/body/uni-app/uni-page/uni-page-wrapper/uni-page-body/uni-view/uni-view[1]/uni-view[3]/uni-input/div/input')
    q_ele.send_keys(f'xxx0{i}00')
    time.sleep(1)
    # 勾选协议
    x_ele = d.find_element(By.XPATH, '/html/body/uni-app/uni-page/uni-page-wrapper/uni-page-body/uni-view/uni-checkbox/div/div')
    x_ele.click()
    time.sleep(1)
    # 点击立即注册
    l_ele = d.find_element(By.XPATH, '/html/body/uni-app/uni-page/uni-page-wrapper/uni-page-body/uni-view/uni-view[2]')
    l_ele.click()
    time.sleep(1)
    d.quit()
    d = webdriver.Chrome()
    d.get("http://192.168.0.125:8008/mobile/pages/register/register")
    time.sleep(1)

d.quit()
